<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('任务下发列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="task-form">
                <div class="select-list">
                    <ul>
                        <li>
                            任务标题：<input type="text" name="taskTitle"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var showFlag = [[${@permission.hasPermi('system:grant:show')}]];
    var prefix = ctx + "system/task/grant";
    $(function() {
        var options = {
            url: prefix + "/list",
            updateUrl: prefix + "/show/{id}",
            modalName: "任务",
            pagination: true,
            showPageGo: true,
            columns: [
                {
                    field : 'taskId',
                    title : '任务编号',
                    sortable: true,
                    align: 'center',
                },
                {
                    field : 'taskTitle',
                    title : '任务标题',
                    align: 'center',
                },
                {
                    field : 'starttime',
                    title : '开始时间',
                    sortable: true,
                    align: 'center',
                },
                {
                    field : 'endtime',
                    title : '结束时间',
                    sortable: true,
                    align: 'center',
                },
                {
                    field : 'userName',
                    title : '下发人',
                    align: 'center',
                },
                {
                    field: 'status',
                    title: '状态',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return statusTools(value);
                    }
                },
                {
                    field : 'priority',
                    title : '紧急程度',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return priorityTools(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + showFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.taskId + '\')"><i class="fa fa-edit"></i>查看</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function priorityTools(value) {
        if (value == 0) {
            return '<p class=\"badge badge-primary\">普通</p>';
        } else if (value == 1) {
            return '<p class=\"badge badge-warning\">紧急</p>';
        } else {
            return '<p class=\"badge badge-danger\">非常紧急</p>';
        }
    }

    function statusTools(value) {
        if (value == 1) {
            return '<p class="badge badge-primary">已完成</p>';
        } else if (value == 2) {
            return '<p class="badge badge-danger">未完成</p>';
        } else {
            return '<p class="badge badge-default">已放弃</p>';
        }
    }

</script>
</body>
</html>